import Vue from 'vue'
import Router from 'vue-router'
// 经济信息
import economicinfo from '@/components/economicinfo'
// 环境信息
import environmeninfo from '@/components/environmeninfo'
// 附近断裂带
import nearfz from '@/components/nearfz'
// 人口信息
import populationinfo from '@/components/populationinfo'
// 地震信息
import seismicinfo from '@/components/seismicinfo'
// 三维地形图
import thd from '@/components/thd'
// 天气信息
import weatherinfo from '@/components/weatherinfo'
import home from '@/components/home'
import error from '@/components/error'
import store from '@/store'
import title from '@/assets/title.json'

Vue.use(Router)

const router = new Router({
  routes: [
    {
    	name: 'home',
    	path: '/home/:eqid',
    	component: home,
    	children: [
    		{
    			name: 'default',
    			path: '',
    			component: seismicinfo
    		},
    		{
    			name: 'seismicinfo',
    			path: 'seismicinfo',
    			component: seismicinfo
    		},
    		{
    			name: 'weatherinfo',
    			path: 'weatherinfo',
    			component: weatherinfo
    		},
    		{
    			name: 'populationinfo',
    			path: 'populationinfo',
    			component: populationinfo
    		},
    		{
    			name: 'economicinfo',
    			path: 'economicinfo',
    			component: economicinfo
    		},
    		{
    			name: 'environmeninfo',
    			path: 'environmeninfo',
    			component: environmeninfo
    		},
    		{
    			name: 'thd',
    			path: 'thd',
    			component: thd
    		},
    		{
    			name: 'nearfz',
    			path: 'nearfz',
    			component: nearfz
    		}
    	]
    },
    {
    	name: 'error',
    	path: '*',
    	component: error
    }
  ]
});
router.beforeEach((to, from , next) => {
    var name = title[to.name];
    store.commit('seteqhead', name);
    next();
});
export default router;
